#include <iostream>

/**
 * https://www.luogu.com.cn/problem/P1980
 */
using namespace std;
int main() {
    int n, x, sum = 0, a;
    cin >> n >> x;
    for (int i = 1; i <= n; i++) {
        a = i;
        while (a != 0) {
            if (a % 10 == x) sum++;
            a /= 10;
        }
    }
    cout << sum;
    return 0;
}